package validation;

import dbmanager.DBManager;

public class Maxlength implements Validation
{
	DBManager db;
	String ConditionValue;
	
	public void setDbmanager(DBManager db)
	{
		this.db=db;
	}
	
	
	public String getMessage()
	{
		return "Length of the value must not exceed "+ConditionValue;
	}

	public boolean validate(String Value) 
	{	
		return false;
	}

	public boolean validate(String actualvalue, String ConditionValue) 
	{
		try
		{
			int maxlength = Integer.parseInt(ConditionValue);
			if((actualvalue.length())<=maxlength)
				return true;
			
		}
		catch (Exception e) 
		{
			e.printStackTrace();			
		}
		return false;
	}

	public boolean validate(String Value, String ConditionValue, String Refvalue) 
	{
		this.ConditionValue = ConditionValue;
		return validate(Value,ConditionValue);
		
	}


	public void setBasicvalue(String value) {
		// TODO Auto-generated method stub
		
	}
	
	public static void main(String[] args) 
	{
		Maxlength fix = new Maxlength();
		System.out.println("Result "+fix.validate("ddg", "3","")+"\n"+fix.getMessage());
		
	}
}
